#include "BartModel.h"
#include <sstream>
#include <hilog/log.h>
using namespace bart;

BartModel::BartModel(const std::string &model_path,
                     const std::string &encode_path)
    : encoder(encode_path) {
  this->classifier = BartClassifier::getInstance(model_path);
}

void printEncodings(const std::vector<int> &ids) {
    std::stringstream ss;
    ss << "[";
  for (auto id : ids) {
      ss << " " << id << ",";
  }
  ss << "]";
  OH_LOG_Print(LOG_APP, LOG_INFO, LOG_DOMAIN, "[CLipNative]", "encoding is %{public}s", ss.str().c_str());
}

at::Tensor BartModel::getPossibility(const std::string &text,
                                     const std::string &text_pair) {
  std::vector encoding = encoder.encode(text, text_pair);
  printEncodings(encoding);
  return this->classifier->getPossibility(encoding);
}